
//% color="#00c4dd" iconWidth=40 iconHeight=40
namespace AirQuality{
	
    //% block="init uart[port_name]baud rate[baud_rate]" blockType="command"
	//% port_name.shadow="string" port_name.defl="/dev/ttyUSB0"
	//% baud_rate.shadow="number" baud_rate.defl="9600"
    export function init(parameter: any, block: any) {
	    let port_name=parameter.port_name.code;
		let baud_rate=parameter.baud_rate.code;
	    Generator.addImport(`from aq import AirQuality`);
		Generator.addCode(`aq = AirQuality(${port_name},${baud_rate})`);	   
    }	
   
	//% block="read and parse data" blockType="boolean"
    export function is_get_data(parameter: any, block: any) {
		Generator.addCode(`aq.read_and_parse_data()`);	   
    }
		
	//% block="get eCO2 data" blockType="reporter"
    export function get_eco2(parameter: any, block: any) {
		Generator.addCode(`aq.data_dict['eCO2']`);	   
    }
		
	//% block="get eCH20 data" blockType="reporter"
    export function get_ech20(parameter: any, block: any) {
		Generator.addCode(`aq.data_dict['eCH20']`);	   
    }	
		
	//% block="get TVOC data" blockType="reporter"
    export function get_tvoc(parameter: any, block: any) {
		Generator.addCode(`aq.data_dict['TVOC']`);	   
    }
		
	//% block="get PM2.5 data" blockType="reporter"
    export function get_pm2d5(parameter: any, block: any) {
		Generator.addCode(`aq.data_dict['PM2.5']`);	   
    }
		
	//% block="get PM10 data" blockType="reporter"
    export function get_pm10(parameter: any, block: any) {
		Generator.addCode(`aq.data_dict['PM10']`);	   
    }
		
	//% block="get Temperature data" blockType="reporter"
    export function get_temperature(parameter: any, block: any) {
		Generator.addCode(`aq.data_dict['temperature']`);	   
    }
		
	//% block="get Humidity data" blockType="reporter"
    export function get_humidity(parameter: any, block: any) {
		Generator.addCode(`aq.data_dict['humidity']`);	   
    }	
}
 